"""
写装饰器，限制函数的执行效率，如10秒一次
"""
import time
def wrapper(func):
    start = 0
    def inner(*args,**kwargs):
        nonlocal start
        now = time.time()
        if now-start>10:
            ret = func(*args,**kwargs)
            start = now
            return ret
        else:  # 小于10秒
            print(f"你访问的太频繁，请{10-(int(now-start))}秒之后访问！")
    return inner

@wrapper
def text():
    print("我要打游戏")

text()
time.sleep(9)
text()
text()
time.sleep(1)
text()
text()
text()
text()